<?php
/**
 * Author:   tangxiaowen
 * Email:    846506584@qq.com
 * Date:     2019/4/9 0009
 * Describe: 登陆注册验证类
 */

namespace app\admin\validate;

use think\Validate;

class Login extends Validate
{
    protected $rule = [
        'Mobile'      => 'require',
        'MsgCode'     => 'require',
        'UserName'    => 'require',
        'Code'        => 'require',
    ];

    protected $message = [
        'Mobile'      => ['require' => '请输入手机号码'],
        'MsgCode'     => ['require' => '请输入短信验证码'],
        'UserName'    => ['require' => '用户名不能为空'],
        'Code'        => ['require' => '请输入图形验证码'],
    ];

    protected $scene = [
        'sendVerify'         => ['Mobile','Code'],
        'register_tuiguang'  => ['Mobile','MsgCode'],
        'daichao'            => ['UserName','Password'],
        'getLoginType'       => ['Mobile'],
        'login'              => ['Mobile'],
    ];

    //验证手机号
    protected function checkPhone($mobile){
        return preg_match('#^13[\d]{9}$|^14[5,7]{1}\d{8}$|^15[\d]{1}\d{8}$|^17[1,0,5,6,7,8,3]{1}|^19[9]{1}\d{8}$|^18[\d]{9}$#', $mobile) ? true : false;
    }
}